<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>


<script>
  function randomNum(a, b) {
    return Math.floor(Math.random() * ( Math.abs(a - b) + 1 )) + Math.min(a, b)
  }
  
  console.log(randomNum(10, 20))
  
  const obj = {}

  for (let i = 0; i < 1000000; i++) {
    const r = randomNum(65, 50)
    
    obj[r] ? obj[r]++ : (obj[r] = 1)
  }
  
  console.log(obj)
  
  /*
    四舍五入
    0 ~ 0.4     0
    0.5 ~ 1.4   1
    ...
    8.5 ~ 9.4   9
    9.5 ~ 9.9   10
    
    向下取整
    0 ~ 0.9     0
    1 ~ 1.9     1
    8 ~ 8.9     8
    9 ~ 9.9     9
  */
  
</script>
</body>
</html>
